home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / EVISION1.ARJ / TMENUBAR.HPP < prev    next >
C/C++ Source or Header  |  1992-05-19  |  7KB  |  124 lines

  1. #if !defined (TMENUBAR)                   // To prevent multiple declarations
  2. #define TMENUBAR
  3.  
  4. // ---- Library Header Files ------------------------------------------------
  5.  
  6. #include <conio.h>
  7.  
  8.  
  9. // ---- Macros --------------------------------------------------------------
  10.  
  11. #include "evmacros.hpp"
  12.  
  13.  
  14. // ---- Type Definitions ----------------------------------------------------
  15.  
  16. #include "twindow.hpp"
  17. #include "tstatusline.hpp"
  18.  
  19.  
  20. struct tmenuitem                                             // One menu item
  21. {
  22.    char huge *itemtext ;                                         // Item text
  23.    int       hotkey ;                       // Hotkey for this item (A-Z & 0)
  24.    int       itemrow ;                               // Row of item in window
  25.    int       returnvalue ;                      // Return value for this item
  26.    int       availflag ;              // TRUE: available FALSE: not available
  27.    char huge *sltext ;                            // Help text for statusline
  28.    tmenuitem huge *nextitem ;                            // Next item in link
  29.    tmenuitem huge *previousitem ;                    // Previous item in link
  30. } ;
  31.  
  32.  
  33. struct tmenu                                                      // One menu
  34. {
  35.    char huge  *name ;                                         // Name of menu
  36.    int        hotkey ;                                // Hotkey of menu (A-Z)
  37.    int        colpos ;                              // Column postion of menu
  38.    char huge  *sltext ;                           // Help text for statusline
  39.    tmenuitem  huge *itemfirst ;                         // First item in link
  40.    tmenuitem  huge *itemlast ;                           // Last item in link
  41.    int        itemcount ;                          // Number of items in menu
  42.    int        itemmaxwidth ;                        // Max width of the items
  43.    int        itemlasthot ;                    // Last selected item (hotkey)
  44.    tmenu huge *nextmenu ;                                // Next menu in link
  45.    tmenu huge *previousmenu ;                        // Previous menu in link
  46. } ;
  47.  
  48.  
  49. // ---- Class Declarations --------------------------------------------------
  50.  
  51. class tmenubar
  52. {
  53.    int  menubackcolor ;                           // Menubar background color
  54.    int  menuforecolor ;                           // Menubar foreground color
  55.    int  menuhighcolor ;                            // Menubar highlight color
  56.    int  menucursorcolor ;                      // Menubar selection bar color
  57.    int  menucount ;                             // Number of menus on menubar
  58.    int  menubarwidth ;                          // Width of all created menus
  59.    int  menulasthot ;                          // Last menu selected (hotkey)
  60.    char        huge *menuhelp ;               // Ptr to help text for menubar
  61.    tmenu       huge *menufirst ;                        // First menu in link
  62.    tmenu       huge *menulast ;                          // Last menu in link
  63.    tstatusline huge *menuslptr ;              // Ptr to the statusline object
  64.  
  65.    int  screenheight ;                                         // Screen size
  66.    int  screenwidth ;                                          // Screen size
  67.  
  68.    public:
  69.  
  70.         far tmenubar () ;                                      // Constructor
  71.         far ~tmenubar () ;                                      // Destructor
  72.  
  73.    void far setcolors                                   // Set menubar colors
  74.       ( int back=LIGHTGRAY,                               // Background color
  75.         int fore=BLACK,                                   // Foreground color
  76.         int high=RED,                                      // Highlight color
  77.         int cursor=GREEN,                                     // Cursor color
  78.         int clockback=RED,                                     // Clock color
  79.         int clockfore=WHITE ) ;
  80.    void far sethelp                               // Set help ptr for menubar
  81.       ( char huge *helptext ) ;      // Ptr to help text while in the menubar
  82.    void far setslptr                                 // Set ptr to statusline
  83.       ( tstatusline huge *slptr ) ;      // Ptr to an instantiated statusline
  84.    void far addmenu                                            // Create menu
  85.       ( char huge *name,                                      // Name of menu
  86.         int       hotkey,                       // Key to activate menu (A-Z)
  87.         char huge *sltext=NULL ) ;           // Statusline text for this menu
  88.    void far additem                                            // Create item
  89.       ( char huge *text="",                                      // Item text
  90.         int       hotkey=0,                   // Item hotkey ('A' to 'Z' & 0)
  91.         int       returnval=0,                // Return value of this command
  92.         char huge *sltext=NULL ) ;                    // Item statusline text
  93.    int  far trough                                        // Activate menubar
  94.       ( int key ) ;                       // Key value to pass trough menubar
  95.    void far itemsetavail                   // Set item availability ON or OFF
  96.       ( int menuhotkey,                     // Hotkey of menu in wich item is
  97.         int itemhotkey,                         // Hotkey of menu item to set
  98.         int state=TRUE ) ;           // TRUE: available  FALSE: Not available
  99.    void far refresh () ;                                // Redraw the menubar
  100.  
  101.    private:
  102.  
  103.    void far menudraw                         // Display 1 menuname on menubar
  104.       ( int hotkey=0,                               // Hotkey of menu to draw
  105.         int cursorflag=0 ) ;                   // 1: Display cursor  0: Don't
  106.    int  far exttoascii                    // Convert 'ALT-letter' to 'letter'
  107.       ( int code ) ;                                       // Code to convert
  108.    tmenu huge* far menuexist              // Check if menu exist. Return addr
  109.       ( int menuhotkey ) ;                          // Hotkey of menu to find
  110.    tmenuitem huge* far itemexist                  // Return item addr or NULL
  111.       ( int menuhotkey,                              // Menu in which to look
  112.         int itemhotkey ) ;                                // Item to look for
  113.    int  far chooseitem () ;                     // Opens menu and choose item
  114.    void far itemdraw                              // Display 1 item in a menu
  115.       ( twindow   huge *winptr,                         // Ptr to menu window
  116.         tmenuitem huge *itemptr,                    // Ptr to item to display
  117.         int            cursorflag=0 ) ;        // 0: Cursor off  1: Cursor on
  118. } ;
  119.  
  120.  
  121. // ---- End Header File ----------------------------------------------------
  122.  
  123. #endif
  124.